#include "DTexture.h"

DTexture::DTexture(void) : m_pTexture(NULL)
{
}

DTexture::~DTexture(void)
{
}

void DTexture::Load( TCHAR* filePath )
{
	TCHAR driver[MAX_PATH];
	TCHAR dir[MAX_PATH];
	TCHAR name[MAX_PATH];
	TCHAR ext[MAX_PATH];

	_tsplitpath_s(filePath, driver, dir, name, ext);
	_tcscpy_s(m_fileName,MAX_PATH,name);
	_tcscat_s(m_fileName,MAX_PATH, ext);
	_tcscpy_s(m_filePath,MAX_PATH,driver);
	_tcscat_s(m_filePath,MAX_PATH,dir);
	_tcscat_s(m_filePath,MAX_PATH,m_fileName);

	Release();
	D3DXCreateTextureFromFile( DDevice::GetInstance()->GetDevice(), 
		filePath, &m_pTexture );
}

void DTexture::Release()
{
	if(m_pTexture != NULL)
	{
		m_pTexture->Release();
		m_pTexture = NULL;
	}
}
